/*--------------------------------------------------------------------------

	Custom Screen Resolution v1.1

  Author:
  Z-ON

  Changelog:
  2018/08/29 Released
	2018/09/03 Added Bottom UI Y config

--------------------------------------------------------------------------*/

// Set the screen resolution.
var ScreenResolution = {
	WIDTH: 832,
	HEIGHT: 640
}

// Set the Y position of the bottom UI of real battle animation (from the bottom).
var BottomUI_y = 13;

/*--------------------------------------------------------------------------
	Do not edit anything below unless you know what you're doing.
--------------------------------------------------------------------------*/

ScriptCall_Initialize = function(startupInfo) {
	startupInfo.setGameAreaWidth(ScreenResolution.WIDTH);
	startupInfo.setGameAreaHeight(ScreenResolution.HEIGHT);
};

var RealBattleArea = {
	WIDTH: ScreenResolution.WIDTH,
	HEIGHT: ScreenResolution.HEIGHT
};

UIBattleLayout._drawFrame = function(isTop) {
	var x, y, graphicsHandle;
	var dx = this._getIntervalX();

	if (isTop) {
		this._drawLifeGadget(339 + dx, 0, this._battlerRight);
		this._drawLifeGadget(220 + dx, 0, this._battlerLeft);

		x = dx;
		y = 0;
		graphicsHandle = this._getTopGraphicsHandle();
	}
	else {
		x = dx;
		y = (0 + this._getBattleAreaHeight()) - (100 + BottomUI_y);
		graphicsHandle = this._getBottomGraphicsHandle();
	}

	if (graphicsHandle !== null) {
		GraphicsRenderer.drawImage(x, y, graphicsHandle, GraphicsType.PICTURE);
	}
};

UIBattleLayout._drawNameArea = function(unit, isRight) {
	var x, y, range;
	var text = unit.getName();
	var color = ColorValue.DEFAULT;
	var font = TextRenderer.getDefaultFont();
	var dx = this._getIntervalX();

	if (isRight) {
		x = 330 + dx;
		y = (0 + this._getBattleAreaHeight()) - (82 + BottomUI_y);
	}
	else {
		x = 115 + dx;
		y = (0 + this._getBattleAreaHeight()) - (82 + BottomUI_y);
	}

	range = createRangeObject(x, y, 185, 25);
	TextRenderer.drawRangeText(range, TextFormat.CENTER, text, -1, color, font);
};

UIBattleLayout._drawWeaponArea = function(unit, isRight) {
	var x, y, width, height, item, text;
	var color = ColorValue.DEFAULT;
	var font = TextRenderer.getDefaultFont();
	var dx = this._getIntervalX();

	if (isRight) {
		item = this._itemRight;
	}
	else {
		item = this._itemLeft;
	}

	if (item === null) {
		return;
	}

	text = item.getName();
	width = TextRenderer.getTextWidth(text, font) + GraphicsFormat.ICON_WIDTH;
	height = 25;

	if (isRight) {
		x = 330 + dx;
		y = (0 + this._getBattleAreaHeight()) - (50 + BottomUI_y);
	}
	else {
		x = 115 + dx;
		y = (0 + this._getBattleAreaHeight()) - (50 + BottomUI_y);
	}

	x += (185 - width) / 2;
	y = Math.floor((y + (y + height)) / 2);

	if (item !== null) {
		ItemRenderer.drawItem(x, y, item, color, font, false);
	}
};

UIBattleLayout._drawFaceArea = function(unit, isRight) {
	var x, y;
	var dx = 20 + this._getIntervalX();
	var isReverse = false;

	if (isRight) {
		x = this._getBattleAreaWidth() - GraphicsFormat.FACE_WIDTH - dx;
	}
	else {
		x = 0 + dx;
		isReverse = true;
	}

	y = (0 + this._getBattleAreaHeight()) - GraphicsFormat.FACE_HEIGHT - (2 + BottomUI_y);

	ContentRenderer.drawUnitFace(x, y, unit, isReverse, 255);
};
